<template>
    <div>
        <!-- 消息提示区域 -->
        <el-row>
            <el-col :span="24">
                <div class="grid-content  bg-purple">
                    欢迎访问后台管理系统：当前时间是：{{ new Date() }}
                </div>
            </el-col>
        </el-row>
        <!-- 商品销售数据区域 -->
        <el-row>
            <el-col :span="6">
                <div class="grid-content bg-purple row">
                    今日库存
                </div>
            </el-col>
            <el-col :span="6">
                <div class="grid-content bg-purple row">
                    在线会员
                </div>
            </el-col>
            <el-col :span="6">
                <div class="grid-content bg-purple row">
                    退款统计
                </div>
            </el-col>
            <el-col :span="6">
                <div class="grid-content bg-purple row">
                    销量统计
                </div>
            </el-col>
        </el-row>
        <!-- echarts 折线堆叠图 -->
        <el-row>
            <el-col :span="24">
                <div class="grid-content  bg-purple tu" ref="tu">
                    <!-- 绘制echarts图表的容器 一定要有宽度和高度-->
                </div>
            </el-col>
        </el-row>

    </div>
</template>

<script>


// 引入 echarts
import * as echarts from "echarts"
export default {
    mounted() {
        // console.log('echarts', echarts)
        this.setEcharts()
    },
    methods: {
        setEcharts() {
            // 画布容器：canvas svg
            // 1.获取echarts实例
            let echartsInstance = echarts.init(this.$refs.tu)
            // console.log(echartsInstance)
            // 2.设置绘制图表的配置项

            let options = {
                title: {
                    text: 'Stacked Line'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
                },
                grid: {
                    left: '3%',
                    right: '4%',
                    bottom: '3%',
                    containLabel: true
                },
                toolbox: {
                    feature: {
                        saveAsImage: {}
                    }
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        name: 'Email',
                        type: 'line',
                        stack: 'Total',
                        data: [120, 132, 101, 134, 90, 230, 210]
                    },
                    {
                        name: 'Union Ads',
                        type: 'line',
                        stack: 'Total',
                        data: [220, 182, 191, 234, 290, 330, 310]
                    },
                    {
                        name: 'Video Ads',
                        type: 'line',
                        stack: 'Total',
                        data: [150, 232, 201, 154, 190, 330, 410]
                    },
                    {
                        name: 'Direct',
                        type: 'line',
                        stack: 'Total',
                        data: [320, 332, 301, 334, 390, 330, 320]
                    },
                    {
                        name: 'Search Engine',
                        type: 'line',
                        stack: 'Total',
                        data: [820, 932, 901, 934, 1290, 1330, 1320]
                    }
                ]
            };
            // 3.使用配置项完成图表的绘制
            echartsInstance.setOption(options)
        }
    }
};
</script>

<style scoped lang="less">
.el-row {
    margin: 20px 0;

    &:last-child {
        margin-bottom: 0;
    }
}

.el-col {
    border-radius: 4px;
}

.bg-purple-dark {
    background: #a6b1c2;
}

.bg-purple {
    background: #d3dce6;
}

.bg-purple-light {
    background: #e5e9f2;
}

.grid-content {
    border-radius: 4px;
    min-height: 36px;
}

.row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
}

.row {
    height: 130px;
    margin: 0 5px;
}

.tu {
    height: 500px;
}
</style>
